package com.example.base.springboot;

import com.example.base.job.Job;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Set;

@Slf4j
@Job("jarload")
public class JobDemo {


    @Autowired
    private DynamicLoad dynamicLoad;

    public void run() throws InstantiationException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException, IOException, InvocationTargetException {
        File file=new File("D:\\mycode\\java\\springboot-base\\app_out");
        if(file.isDirectory()){
            File[] files=file.listFiles();
            for (int i = 0; i < files.length ; i++) {
                File f=files[i];
                dynamicLoad.loadJar(f);
            }
        }
        log.info("运行了");
    }
}
